<%-- 
    Document   : detailproday
    Created on : Nov 20, 2011, 1:35:52 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.*,Beans.NgonNgu, Beans.ThamSoHT, Models.ThamSoHT_Model, Models.MonAn_Model, Models.NhomMA_Model"%>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'chkpromsg', 'checksubmitmsg', 'discount', 'detailpromotionday', 'notice', 'promotion', 'rightmsg', 'foodgroupsname' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.
            String checksubmitmsg = mdsts[0].getTenTS();
            String chkpromsg = mdsts[1].getTenTS();
            String detailpromotionday = mdsts[2].getTenTS();
            String discount = mdsts[3].getTenTS();
            String foodgroupsname = mdsts[4].getTenTS();
            String notice = mdsts[5].getTenTS();
            String promotion = mdsts[6].getTenTS();
            String rightmsg = mdsts[7].getTenTS();
            String msgchkpro = notice + "/" + chkpromsg;
            String msgright = notice + "/" + rightmsg;
            String msgsubmit = notice + "/" + checksubmitmsg;
            
            Vector vDSNT = (Vector) request.getAttribute("DSNT");
            Vector vDSNMA = (Vector) request.getAttribute("DSNMA");
            String makm = (String) request.getAttribute("makm");

            int MaNMA = NhomMA_Model.LayMaNMA();
            int total = 0;

%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<h1><img style="margin-right: 13px; opacity: 0.8; margin-top: 4px;" alt="" src="../images/promotion11.png"><%=promotion%></h1>
<div class="cb"></div>
<div class="bloc" style=" margin-top: 15px;">
    <div class="title">
        <%=detailpromotionday%>        
    </div>
    <div class="content">
        <form name="AddDetailProDay" action="">
            <div  style="float: left; width: 22%; margin-bottom: 15px;">
                <label><%=foodgroupsname%></label>
                <select name="nhomma" class="text" style=" margin-bottom: 15px; padding-top: 3px; height: 27px;" lang="1" onchange="ShowListFood(this.lang, this.value)">
                <%
                    for(int i=0; i<vDSNMA.size(); i++){
                        Beans.NhomMA nma = (Beans.NhomMA) vDSNMA.elementAt(i);%>
                        <option value="<%=nma.getMaNMA() %>"><%=nma.getTenNMA() %></option>
                <%  }%>
                </select>
                <div class="cb"></div>
                <div id="dsma">
                <%
                    Vector vDSMA = new Vector();
                    vDSMA = MonAn_Model.LayDSMATheoNMA(langid, MaNMA);
                    int numpage = 0;// khởi tạo số trang = 0
                    int vsize = vDSMA.size();
                    if (vsize % 10 == 0) // mỗi trang có 6 dòng
                    {
                        numpage = vsize / 10;
                    } else {
                        numpage = vsize / 10 + 1;
                    }
                    String xx = "1";
                    int item = Integer.parseInt(xx);
                    
                    for (int j = (item - 1) * 10; j < (item - 1) * 10 + 10 && j < vsize; j++){
                        Beans.MonAn ma = (Beans.MonAn) vDSMA.elementAt(j);%>
                        <% total = total + 1; %>
                        <div style=" width: 30px; float: left;"><input type="checkbox" name="chkma" alt="<%=ma.getMaMA() %>"></div>
                    
                        <div><%=ma.getTenMA() %></div><br />
                <%  }
                %>
                <input type="hidden" name="total" value="<%=total%>">
                <div class="pagination" style=" margin-right: 20px;">
                <%
                    int trang = 1;
                    if (item > 1) {
                        trang = item - 1;
                    }
                %>
                <%
                    if (vsize > 10) {%>
                        <a href="#" class="prev"  name="<%= trang%>" lang="<%=MaNMA %>" onclick="ShowListFood( this.name, this.lang)">«</a>
                <%      for (int c = 1; c <= numpage; c++) {
                            if (c != item) {
                %>              <a href="#"  name="<%= c%>" lang="<%=MaNMA %>" onclick="ShowListFood( this.name, this.lang)" ><%= c%></a>
                <%          } else {%><a class="current"> <%= c%></a> <% }
                        }
                %>
                <%      if (item + 1 <= numpage) {
                            trang = item + 1;
                        } else {
                            trang = item;
                        }
                %>
                        <a href="#" class="next"  name="<%= trang%>" lang="<%=MaNMA %>" onclick="ShowListFood( this.name, this.lang)">»</a>
                <%  }
                %>
            </div>
                </div>
            </div>
            <div style="float: left; width: 15%; margin-bottom: 15px;">
                <label><%=discount%></label>
                <input type="textbox" class="text" onkeypress="return keypress(event)" name="discount" maxlength="2" style=" width: 40px; margin-bottom: 15px;">  %
                <div class="cb"></div>
                <%
                    for(int k=0; k<vDSNT.size(); k++){
                        Beans.NgayThu nt = (Beans.NgayThu) vDSNT.elementAt(k);
                        if(nt.getMaNgay() == 0){%>
                        <div style=" width: 30px; float: left;"><input type="checkbox" onclick="CheckAllNT()"  name="radnt" alt="<%=nt.getMaNgay() %>"></div>
                            <div><%=nt.getTenNgay() %></div><br />
                <%      }
                        else{%>
                        <div style=" width: 30px; float: left;"><input type="checkbox"  name="chknt" alt="<%=nt.getMaNgay() %>"></div>
                            <div><%=nt.getTenNgay() %></div><br />
                <%      }
                  }
                %>
                <input type="button" alt="<%=makm %>" id="<%=msgsubmit%>" lang="<%=msgchkpro%>" name="<%=msgright%>" onclick="AddProDay( this.alt, this.id, this.lang, this.name)" class="button" value=">>">
            </div>
            <div id="detailproday" style="float: left; width: 63%; margin-bottom: 15px;">
                
            </div>

        </form>
    </div>
</div>